#ifndef _BG_DECAL_H_
#define _BG_DECAL_H_

#include "ui/ui_sprite.h"
#include "bg_element.h"

namespace background
{
class	BGDecal : public BGElement
{
public:
	enum		DECAL_TYPES
	{
		DECAL_PLAIN,
		DECAL_PAN,
		DECAL_ROT,
		DECAL_BOB,
		DECAL_UV,
		DECAL_GLOW,
		DECAL_C
	};
							BGDecal(BGScene*	pScene);
	virtual					~BGDecal();
	virtual void			Render(const math::Vec2& Offset, float	Scale) ;
	virtual void			Tick(float dt);
	virtual void			Load(LuaPlus::LuaObject& Obj);
	virtual void			Save(script::WriteLua* pWL);
	virtual void			SetSprite(const std::string& Sprite);
	bool					GetAdditive() const { return m_Additive; };
	void					SetAdditive(bool b) { m_Additive = b; };
	void					SetAlpha(float f) { m_Alpha = f; };
	float					GetAlpha() const { return m_Alpha; };
	virtual bool			MatchSubStr(const std::string& SubStr); 
	virtual void			FlushImages();
	virtual void			OnElementReset();
	virtual const char*		GetName()  { return m_SpriteImg.c_str(); };

protected:
	virtual	void			CopyData(BGElement*	pFrom)
	{
		BGElement::CopyData(pFrom);
		BGDecal* pDecal = (BGDecal*)pFrom;
		m_Additive = pDecal->m_Additive;
		m_SpriteImg = pDecal->m_SpriteImg;
		m_Timer = pDecal->m_Timer;
		m_Alpha = pDecal->m_Alpha;
		m_InitialAdditive = pDecal->m_InitialAdditive;
		m_InitialAlpha = pDecal->m_InitialAlpha;
	}
	bool					m_Additive;
	ui::UISprite			m_Sprite;
	std::string				m_SpriteImg;
	float					m_Timer;	
	float					m_Alpha;

private:
	float					m_InitialAlpha;
	bool					m_InitialAdditive;

};

class	BGPanDecal		: public BGDecal 
{
public:
							BGPanDecal(BGScene*	pScene)  :BGDecal(pScene) { 	m_Type = ELEMENT_PANDECAL;};
	virtual void			Tick(float dt) { Pan(dt); BGDecal::Tick(dt); };
};

class	BGRotDecal		: public BGDecal
{
public:
							BGRotDecal(BGScene*	pScene)  :	BGDecal(pScene) { m_Type = ELEMENT_ROTDECAL;};
	virtual void			Tick(float dt) { Rotate(dt); BGDecal::Tick(dt); };
};

class	BGBobDecal		: public BGDecal
{
public:
							BGBobDecal(BGScene*	pScene)  :BGDecal(pScene) { m_Type = ELEMENT_BOBDECAL;};
	virtual void			Tick(float dt) { m_Timer+=dt; BGDecal::Tick(dt); };
	virtual void			Render(const math::Vec2& Offset, float Scale) ;
protected:
};

class	BGUVDecal		: public BGDecal
{
public:
							BGUVDecal(BGScene*	pScene)  :BGDecal(pScene) { m_Type = ELEMENT_UVDECAL;};
	virtual void			Tick(float dt) { m_Timer+=dt; BGDecal::Tick(dt); };
	virtual void			Render(const math::Vec2& Offset, float Scale) ;
protected:
};

class	BGGlowDecal		: public BGDecal
{
public:
							BGGlowDecal(BGScene*	pScene)  :BGDecal(pScene) { m_Type = ELEMENT_GLOWDECAL;};
	virtual void			Tick(float dt) { m_Timer+=dt; BGDecal::Tick(dt); };
	virtual void			Render(const math::Vec2& Offset, float Scale) ;
protected:
};

}  // namespace background

#endif // _BG_DECAL_H_